﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once
#include "GmFamilyService.h"
#include "IExternalObject.h"

namespace gfam
{
    // \brief  族对象通用基类
    class GM_FAMILY_SERVICE_EXPORT IFamilyEntity : public gcmp::IExternalObject
    {
        DEFINE_CAST_DERIVED(gfam::IFamilyEntity, gcmp::IExternalObject)

    public:
        /// \brief 获取所属Element的id
        /// 
        /// \return 所属Element的Id
        virtual gcmp::ElementId GetOwnerElementId() const = 0;

        /// \brief 获得主对象的Id
        /// 主对象指具有强依赖关系的对象，当主对象被删除时，从对象也会被删除。
        ///
        /// \return ElementId 主对象的Id
        virtual gcmp::ElementId GetMasterId() const = 0;

        /// \brief 转换Owner Element为IFamilyEntity类型
        /// 
        /// \return 转换失败返回nullptr
        static IFamilyEntity* CastElement(gcmp::IElement* pOwnerElement);

        /// \brief 转换Owner Element为IFamilyEntity类型
        /// 
        /// \return 转换失败返回nullptr
        static const IFamilyEntity* CastElement(const gcmp::IElement* pOwnerElement);


        /// \brief 根据ElementId获取族对象
        /// 
        /// \param pDocument 文档指针
        /// \param id 对象id
        /// \return 返回族对象
        static IFamilyEntity* GetByElementId(const gcmp::IDocument* pDocument, const gcmp::ElementId& id);

        /// \brief 获取ImplementationUid
        /// 
        /// \return ImplementationUid
        static gcmp::UniIdentity GetImplementationUid();

    };

} 
